package com.mszlu.news.controller;

import com.mszlu.news.service.FollowService;
import com.mszlu.news.vo.Result;
import com.mszlu.news.vo.params.FollowParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "关注接口")
@RestController
@RequestMapping("follow")
public class FollowController {
    @Autowired
    private FollowService followService;

    @ApiOperation(value = "通过用户id查找粉丝列表")
    @PostMapping("fanlist/{userId}")
    public Result listFan(@PathVariable("userId") Long userId) {
        return followService.listFanByUserId(userId);
    }

    @ApiOperation(value = "通过用户id查找关注人列表")
    @PostMapping("followlist/{userId}")
    public Result listFollow(@PathVariable("userId") Long userId) {
        return followService.listFollowByUserId(userId);
    }

    @ApiOperation(value = "增加关注")
    @PostMapping("add")
    public Result addFollow(@RequestBody FollowParam followParam){
        return followService.addFollow(followParam);
    }

    @ApiOperation(value = "取消关注")
    @PostMapping("delete")
    public Result deleteFollow(@RequestBody FollowParam followParam){
        return followService.deleteFollow(followParam);
    }

    @ApiOperation(value = "通过用户id查找关注用户和粉丝个数")
    @PostMapping("count/{userId}")
    public Result Counts(@PathVariable("userId") Long userId) {
        return followService.Counts(userId);
    }
}
